<template>
  <div>
    <el-row>
      <el-form label-width="auto">
        <el-col :span="4" :offset="4">
          <el-form-item label="提供者">
            <el-tag type="warning" effect="plain">{{
              supplier.nickname
            }}</el-tag>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="获得者">
            <el-tag
              type="danger"
              effect="plain"
              v-text="consumer.nickname"
            ></el-tag>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="数量">
            <el-input v-model.number="dealBill.quantity"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="交易备注">
            <el-input v-model="dealBill.dealNote"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-button @click="dealBillSubmit()">提交</el-button>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>

<script>
// import New from './components/New.vue';
export default {
  name: "GoldCoinDeal",
  components: {
    // New,Old,
  },
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
    supplier: {
      type: Object,
    },
    consumer: {
      type: Object,
    },
    /*
    *     <!--     {
      "playerId": 170,
      "playerCode": "8110727",
      "nickname": "黄楷文",
      "goldCoin": 58,
      "silverCoin": 85,
      "profession": "writer",
      "usernameFk": "2016207210",
      "version": 0
    }, -->*/
  },
  data() {
    return {
      sampleD: "value",
      dealBill: {
        consumerCode: "8110000",
        supplierCode: "8120000",
        quantity: 10,
        dealNote: "暂时一个交易",

        dealState: "willing",
        dealTime: null,
        dealBillId: 0,
        version: 0,
      },
    };
  },
  computed: {
    // sampleC() {
    //     return this.sampleD+'--';
    // }
  },
  created() {},
  mounted() {},
  methods: {
    sampleM() {},
    dealBillSubmit() {
      // this.dealBill.supplierCode = this.supplier.playerCode;
      // this.dealBill.consumerCode = this.consumer.playerCode;
      this.$message.success(JSON.stringify(this.dealBill));
      this.$http({
        method: "post",
        url: "/ceto/dealBill/insert",
        data: this.dealBill,
      }).then(
        (res) => {
          if (res.data) {
            this.$emit("postSubmit");
          }
        },
        (error) => {
          console.log(".dealBill request error : " + error.response.status);
        }
      );
    },
  },
  watch: {
    supplier(newValue, oldValue) {
      this.dealBill.supplierCode = newValue.playerCode;
    },
    consumer(newValue, oldValue) {
      this.dealBill.consumerCode = newValue.playerCode;
    },
    // sampleC(newValue, oldValue) {
    //
    // }
  },
};
</script>

<!--<style scoped>-->
<style lang="scss" scoped>
span {
  background-color: aliceblue;
}
.el-form-item__content {
  display: flex;
}
.el-tag {
  padding: 0 20px;
}
</style>
